from django.db import models
from datetime import datetime


class Wordform(models.Model):
    pass

class Lemma(models.Model):
    spelling = models.CharField(max_length=500)
    verified = models.BooleanField(default=False)
    verification_comment = models.TextField(blank=True)
    created = models.DateTimeField(auto_now_add=True, default=datetime.now())
    # TODO: more here
    

class POSCommon(models.Model):
    spelling = models.CharField(max_length=500)
    lemma = models.ForeignKey(Lemma, related_name="%(class)s_pos")
    verified = models.BooleanField(default=False)
    verification_comment = models.TextField(blank=True)
    created = models.DateTimeField(auto_now_add=True, default=datetime.now())
    wordform = models.ForeignKey(Wordform, related_name="%(class)s_pos", null=True)


class Noun(POSCommon):
    SUBCLASS = [
        ('0', 'noun'),
        ('a', 'nouna'),
        ('n', 'name'),
        ('s', 'surname'),
        ('p', 'patronimic')
    ]

    CASE = [
        ('1', 'nom'),
        ('2', 'gen'),
        ('3', 'dat'),
        ('4', 'acc'),
        ('5', 'abl'),
        ('6', 'loc'),
        ('7', 'part'),
        ('8', 'rloc'),
        ('9', 'count'),
        ('x', 'CASE')
    ]

    NUMBER = [
        ('s', 'sg'),
        ('p', 'pl'),
        ('x', 'NUMBER')
    ]

    GENDER = [
        ('m', 'masc'),
        ('f', 'fem'),
        ('n', 'neut'),
        ('j', 'masc|fem'),
        ('x', 'GENDER')
    ]

    ANIM = [
        ('a', 'anim'),
        ('i', 'inanim'),
        ('x', 'ANIM')
    ]

    sub = models.CharField(max_length=1, choices=SUBCLASS)
    case = models.CharField(max_length=1, choices=CASE)
    number = models.CharField(max_length=1, choices=NUMBER)
    gender = models.CharField(max_length=1, choices=GENDER)
    anim = models.CharField(max_length=1, choices=ANIM)

class Adjective(POSCommon):
    SUBCLASS = [
        ('0', 'adj'),
        ('a', 'adj_pred'),
        ('p', 'adj_pron')
    ]
    CASE = [
        ('1', 'nom'),
        ('2', 'gen'),
        ('3', 'dat'),
        ('4', 'acc'),
        ('5', 'abl'),
        ('6', 'loc'),
        ('9', 'count'),
        ('x', 'CASE')
    ]

    NUMBER = [
        ('s', 'sg'),
        ('p', 'pl'),
        ('x', 'NUMBER')
    ]

    GENDER = [
        ('m', 'masc'),
        ('f', 'fem'),
        ('n', 'neut'),
        ('x', 'GENDER')
    ]

    ANIM = [
        ('a', 'anim'),
        ('i', 'inanim'),
        ('x', 'ANIM')
    ]

    PROTY = [
         ('q', 'ques'),
         ('i', 'indef'),
         ('n', 'neg'),
         ('r', 'relat'),
         ('u', 'univ'),
         ('s', 'exist'),
         ('m', 'emph'),
         ('d', 'demon'),
         ('1', 'sfirst'),
         ('2', 'ssecond'),
         ('3', 'sthirdfem'),
         ('4', 'sthirdmn'),
         ('6', 'pfirst'),
         ('7', 'psecond'),
         ('8', 'pthird'),
         ('f', 'refl')
    ]

    sub = models.CharField(max_length=1, choices=SUBCLASS)
    case = models.CharField(max_length=1, choices=CASE)
    number = models.CharField(max_length=1, choices=NUMBER)
    gender = models.CharField(max_length=1, choices=GENDER)
    anim = models.CharField(max_length=1, choices=ANIM)
    proty = models.CharField(max_length=1, choices=PROTY)

class Verb(POSCommon):
    SUBCLASS = [
        ('0', 'predicate'),
        ('i', 'infinitive'),
        ('p', 'participle'),
        ('r', 'participle_pr'),
        ('d', 'dee_participle')
    ]
    ASPECT = [
        ('i', 'imperf'),
        ('p', 'perf'),
        ('x', 'ASPECT')
    ]
    VOICE = [
        ('a', 'active'),
        ('p', 'passive'),
        ('r', 'reflexive'),
        ('i', 'interactive')
    ]
    MOOD = [
        ('p', 'past'),
        ('f', 'fut'),
        ('u', 'presfut'),
        ('s', 'subj'),
        ('i', 'imper')
    ]
    TRANS = [
        ('t', 'tran'),
        ('i', 'intran')
    ]
    VERBREFL = [
        ('n', 'vnon'),
        ('r', 'vrefl')
    ]
    PERSON = [
        ('1', 'first'),
        ('2', 'second'),
        ('3', 'third'),
        ('i', 'impers'),
        ('d', 'indef')
    ]
    TAXIS = [
        ('s', 'rpast'),
        ('p', 'rpres')
    ]
    NUMBER = [
        ('s', 'sg'),
        ('p', 'pl')
    ]
    GENDER = [
        ('m', 'masc'),
        ('f', 'fem'),
        ('n', 'neut'),
        ('x', 'GENDER')
    ]
    CASE = [
        ('1', 'nom'),
        ('2', 'gen'),
        ('3', 'dat'),
        ('4', 'acc'),
        ('5', 'abl'),
        ('6', 'loc'),
        ('7', 'count')
    ]
    ANIM = [
        ('a', 'anim'),
        ('i', 'inanim'),
        ('x', 'ANIM')
    ]

    sub = models.CharField(max_length=1, choices=SUBCLASS)
    aspect = models.CharField(max_length=1, choices=ASPECT)
    voice = models.CharField(max_length=1, choices=VOICE)
    mood = models.CharField(max_length=1, choices=MOOD)
    trans = models.CharField(max_length=1, choices=TRANS)
    verbrefl = models.CharField(max_length=1, choices=VERBREFL)
    person = models.CharField(max_length=1, choices=PERSON)
    taxis = models.CharField(max_length=1, choices=TAXIS)
    number = models.CharField(max_length=1, choices=NUMBER)
    gender = models.CharField(max_length=1, choices=GENDER)
    case = models.CharField(max_length=1, choices=CASE)
    anim = models.CharField(max_length=1, choices=ANIM)

class Adverb(POSCommon):
    SUBCLASS = [
                ('0', 'adverb'),
                ('r', 'adverb_pred'),
                ('d', 'adverb_degre'),
                ('c', 'compar'),
                ('p', 'adv_pron')
                ]
    PROTY = [
             ('q', 'ques'),
             ('i', 'indef'),
             ('n', 'neg'),
             ('r', 'relat'),
             ('u', 'univ'),
             ('d', 'demon'), 
             ('1', 'sfirst'),
             ('2', 'ssecond'),
             ('3', 'sthirdfem'),
             ('4', 'sthirdmn'),
             ('6', 'pfirst'),
             ('7', 'psecond'),
             ('8', 'pthird'),
             ('f', 'refl')
             ]

    sub = models.CharField(max_length=1, choices=SUBCLASS)
    proty = models.CharField(max_length=1, choices=PROTY)

class Pronoun(POSCommon):
    SUBCLASS = [
                ('0', 'pronoun'),
                ('p', 'personal'),
                ('r', 'prepositional')
                ]
    PROTY = [
             ('q', 'ques'),
             ('i', 'indef'),
             ('n', 'neg'),
             ('r', 'relat')
             ]
    PERSON = [
              ('1', 'first'),
              ('2', 'second'),
              ('3', 'third'),
              ('i', 'interactive'),
              ('f', 'refl')
              ]
    CASE = [
            ('1', 'nom'),
            ('2', 'gen'),
            ('3', 'dat'),
            ('4', 'acc'),
            ('5', 'abl'),
            ('6', 'loc'),
            ('x', 'CASE')
            ]
    NUMBER = [
              ('s', 'sg'),
              ('p', 'pl'),
              ('x', 'NUMBER')
              ]
    GENDER = [
              ('m', 'masc'),
              ('f', 'fem'),
              ('n', 'neut'),
              ('j', 'masc|fem'),
              ('x', 'GENDER')
              ]
    ANIM = [
            ('a', 'anim'),
            ('i', 'inanim'),
            ('x', 'ANIM')
            ]

    sub = models.CharField(max_length=1, choices=SUBCLASS)
    proty = models.CharField(max_length=1, choices=PROTY)
    person = models.CharField(max_length=1, choices=PERSON)
    case = models.CharField(max_length=1, choices=CASE)
    number = models.CharField(max_length=1, choices=NUMBER)
    gender = models.CharField(max_length=1, choices=GENDER)
    anim = models.CharField(max_length=1, choices=ANIM)

class Numbers(POSCommon):
    SUBCLASS = [
                ('0', 'numeral'),
                ('c', 'collective'),
                ('p', 'pronoun')
                ]
    CASE = [
            ('1', 'nom'),
            ('2', 'gen'),
            ('3', 'dat'),
            ('4', 'acc'),
            ('5', 'abl'),
            ('6', 'loc')
            ]
    QUANT = [
             ('s', 'small'),
             ('p', 'plur')
             ]
    GENDER = [
              ('m', 'masc'),
              ('f', 'fem'),
              ('n', 'neut'),
              ('x', 'GENDER')
              ]
    ANIM = [
            ('a', 'anim'),
            ('i', 'inanim'),
            ('x', 'ANIM')
            ]
    PROTY = [
             ('q', 'ques'),
             ('i', 'indef'),
             ('n', 'neg'),
             ('r', 'relat')
             ]

    sub = models.CharField(max_length=1, choices=SUBCLASS)
    case = models.CharField(max_length=1, choices=CASE)
    quant = models.CharField(max_length=1, choices=QUANT)
    gender = models.CharField(max_length=1, choices=GENDER)
    anim = models.CharField(max_length=1, choices=ANIM)
    proty = models.CharField(max_length=1, choices=PROTY)

class Preposition(POSCommon):
    SUBCLASS = [
                ('1', 'source'),
                ('2', 'other')
                ]
    CASE = [
            ('1', 'nom'),
            ('2', 'gen'),
            ('3', 'dat'),
            ('4', 'acc'),
            ('5', 'abl'),
            ('6', 'loc'),
            ('7', 'part'),
            ('8', 'rloc')
            ]

    sub = models.CharField(max_length=1, choices=SUBCLASS)
    case = models.CharField(max_length=1, choices=CASE)

class Conjunction(POSCommon):
    SUBCLASS = [
                ('1', 'coord'),
                ('2', 'subord')
                ]

    sub = models.CharField(max_length=1, choices=SUBCLASS)

class Particle(POSCommon):
    SUBCLASS = [
                ('0', 'cons'),
                ('1', 'topic'),
                ('n', 'predneg')
                ]
    PROTY = [
             ('q', 'ques'),
             ('i', 'indef'),
             ('n', 'neg')
             ]

    sub = models.CharField(max_length=1, choices=SUBCLASS)
    proty = models.CharField(max_length=1, choices=PROTY)

class Interjection(POSCommon):
    pass